<template>
    <div class="content">
        <div class="left">
            <span class="homeBtn" @click="goHome">首页</span>
        </div>
        <div class="center">
            <span>数据大屏</span>
        </div>
        <div class="right">
            <!-- <span class="homeBtn">统计报告</span> -->
            <i>当前时间: {{ time }}</i>
        </div>
    </div>
</template>

<script setup lang="ts">
import { useRouter } from 'vue-router';
const $router = useRouter()

import moment from 'moment';
import { onBeforeUnmount, onMounted, ref } from 'vue';

const time = ref(moment().format('YYYY年MM月DD日 HH:mm:ss'))

const goHome = () => {
    $router.push('/home')
}

const timeInterval = ref()
const getTime = () => {
    timeInterval.value = setInterval(() => {
        time.value = moment().format('YYYY年MM月DD日 HH:mm:ss')
    }, 1000)
}

onMounted(() => {
    getTime()
})

onBeforeUnmount(() => {
    clearInterval(timeInterval.value)
})

</script>

<style lang="scss" scoped>
.content {
    width: 100%;
    display: flex;
    height: 5%;
    color: #18b1be;

    .left,
    .right {
        flex: 1.5;
        height: 100%;
        background-image: url('@/assets/images/dataScreen-header-left-bg.png');
        background-repeat: no-repeat;
        background-size: 100% 100%;

        .homeBtn {
            height: 100%;
            background-image: url('@/assets/images/dataScreen-header-btn-bg-l.png');
            background-repeat: no-repeat;
            background-size: 100% 100%;
            padding: 0 2.5vw;
            font-size: 1.3vw;
            float: right;
            display: flex;
            align-items: center;
            cursor: pointer;
        }
    }

    .right {
        background-image: url('@/assets/images/dataScreen-header-right-bg.png');
        display: flex;
        justify-content: space-between;
        align-items: center;

        .homeBtn {
            background-image: url('@/assets/images/dataScreen-header-btn-bg-r.png');
        }

        i {
            font-size: 1vw;
            padding-right: 0.5vw;
        }
    }

    .center {
        flex: 2;
        height: 100%;
        background-image: url('@/assets/images/dataScreen-header-center-bg.png');
        background-repeat: no-repeat;
        background-size: 100% 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-weight: 600;
        font-size: 1.8vw;
    }
}
</style>